<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
    xmlns:kiwi="http://www.kiwi-project.eu/jsf"
    xmlns:c="http://java.sun.com/jstl/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:a="http://richfaces.org/a4j">

		<style>
	        .inplace{
	            border: none;
	            cursor:pointer; 
	        }
	        .hover {
	            color: #{a4jSkin.generalTextColor};
	            background-color :#{a4jSkin.tipBorderColor};
	        }   
		   
		   .typelist td {
		   		vertical-align: top;
		   }
	    </style> 
		
		<h1>Class perspective for<h:outputText value=" "/><h:outputText property="http://www.kiwi-project.eu/kiwi/core/title"/></h1>
		
		<p style="margin-top: 20px; margin-left: 10px; margin-right: 10px;" class="help">
		  The content item currently displayed represents either an RDFS or an OWL class. Using this perspective,
		  you can get additional class related information about the content item, i.e. the sub- and superclasses, instances, etc.
		  When you switch to "edit" mode, some of this information can also be edited. Note that inferred metadata is listed 
		  separately. When hovering the mouse over inferred data, an explanation justifying its existance is displayed.
		</p>

		<br/>

		<!-- list of superclasses (needs proper layouting) -->
		<p:panel header="Superclasses" footer="The currently displayed item is in a rdfs:subClassOf relation with the resources listed above.">
	    	<strong>Base:</strong><br/>
			<c:forEach items="#{ontologyService.listSuperClasses(contentItem.resource,false)}" var="sc" varStatus="status">
	    		<h:outputLink value="#{configurationService.baseUri}/home.seam?kiwiid=#{kiwi.ui.utility.encodeURL(sc.kiwiIdentifier)}">
					<h:outputText value="#{sc.label} (#{sc.namespacePrefix})" />
				</h:outputLink>
				<c:if test="#{not status.last}">,<h:outputText value=" "/></c:if>
	    	</c:forEach>
			<br/>
	    	<strong>Inferred:</strong><br/>
			<c:forEach items="#{ontologyService.listSuperClasses(contentItem.resource,true)}" var="sc" varStatus="status">
                <s:link view="/home.xhtml" value="#{sc.label} (#{sc.namespacePrefix})"  propagation="none">
                    <f:param name="title"/><f:param name="uri"/><f:param name="id" /><f:param name="kiwiid" value="#{sc.kiwiIdentifier}"/>
                    <rich:toolTip attached="true" layout="block">
			            <f:facet name="defaultContent">
			                <strong>Please wait...</strong>
			            </f:facet>
                
						<h:dataTable value="#{explanationService.explainTripleTextually(superclassTripleIds.get(sc), true)}" var="story">
						  <h:column>
		                	<h:outputText value="#{story.openingLine.body}" escape="false" style="font-weight:bold"/><h:outputText value=" #{story.openingLine.connective}" style="margin-left:5px"/>
		                	<br/>
						  	<h:dataTable value="#{story.body}" var="line">
						  		<h:column>
						  			<h:outputText value="#{line.body}" escape="false" style="font-weight:bold; margin-left:15px"/> <h:outputText value=" #{line.connective}" style="margin-left:5px"/> <br/>
						  		</h:column>
						  	</h:dataTable>
						  	<br/> <br/>
						  </h:column>
						</h:dataTable>						                
                    </rich:toolTip>    
                </s:link>
				<c:if test="#{not status.last}">,<h:outputText value=" "/></c:if>
	    	</c:forEach>			
		</p:panel>
		
		<br/>

		<!-- list of subclasses (needs proper layouting) -->
		<p:panel header="Subclasses" footer="The resources listed above are in a rdfs:subClassOf relation with the currently displayed item (max 100 resources shown).">
	    	<strong>Base:</strong><br/>
	    	<c:forEach items="#{ontologyService.listSubClasses(contentItem.resource,false)}" var="sc" varStatus="status">
	    		<h:outputLink value="#{configurationService.baseUri}/home.seam?kiwiid=#{kiwi.ui.utility.encodeURL(sc.kiwiIdentifier)}">
					<h:outputText value="#{sc.label} (#{sc.namespacePrefix})" />
				</h:outputLink>
				<c:if test="#{not status.last}">,<h:outputText value=" "/></c:if>
	    	</c:forEach>
			<br/>
	    	<strong>Inferred:</strong><br/>
	    	<c:forEach items="#{ontologyService.listSubClasses(contentItem.resource,true)}" var="sc" varStatus="status">
                <s:link view="/home.xhtml" value="#{sc.label} (#{sc.namespacePrefix})"  propagation="none">
                    <f:param name="title"/><f:param name="uri"/><f:param name="id" /><f:param name="kiwiid" value="#{sc.kiwiIdentifier}"/>
                    <rich:toolTip attached="true" layout="block">
			            <f:facet name="defaultContent">
			                <strong>Please wait...</strong>
			            </f:facet>
                
						<h:dataTable value="#{explanationService.explainTripleTextually(subclassTripleIds.get(sc), true)}" var="story">
						  <h:column>
		                	<h:outputText value="#{story.openingLine.body}" escape="false" style="font-weight:bold"/><h:outputText value=" #{story.openingLine.connective}" style="margin-left:5px"/>
		                	<br/>
						  	<h:dataTable value="#{story.body}" var="line">
						  		<h:column>
						  			<h:outputText value="#{line.body}" escape="false" style="font-weight:bold; margin-left:15px"/> <h:outputText value=" #{line.connective}" style="margin-left:5px"/> <br/>
						  		</h:column>
						  	</h:dataTable>
						  	<br/> <br/>
						  </h:column>
						</h:dataTable>						                
                    </rich:toolTip>    
                </s:link>
				<c:if test="#{not status.last}">,<h:outputText value=" "/></c:if>
	    	</c:forEach>
		</p:panel>

		<br/>

		<p:panel header="Instances" footer="The resources listed above are in a rdf:type relation with the currently displayed item (max 100 resources shown).">
	    	<strong>Base:</strong><br/>
	    	<c:forEach items="#{ontologyService.listInstances(contentItem.resource,false)}" var="sc" varStatus="status">
	    		<h:outputLink value="#{configurationService.baseUri}/home.seam?kiwiid=#{kiwi.ui.utility.encodeURL(sc.kiwiIdentifier)}">
					<h:outputText value="#{sc.label} (#{sc.namespacePrefix})" />
				</h:outputLink>
				<c:if test="#{not status.last}">,<h:outputText value=" "/></c:if>
	    	</c:forEach>
			<br/>
	    	<strong>Inferred:</strong><br/>
	    	<c:forEach items="#{ontologyService.listInstances(contentItem.resource,true)}" var="sc" varStatus="status">
                <s:link view="/home.xhtml" value="#{sc.label} (#{sc.namespacePrefix})"  propagation="none">
                    <f:param name="title"/><f:param name="uri"/><f:param name="id" /><f:param name="kiwiid" value="#{sc.kiwiIdentifier}"/>
                    <rich:toolTip attached="true" layout="block">
			            <f:facet name="defaultContent">
			                <strong>Please wait...</strong>
			            </f:facet>
                
						<h:dataTable value="#{explanationService.explainTripleTextually(instanceTripleIds.get(sc), true)}" var="story">
						  <h:column>
		                	<h:outputText value="#{story.openingLine.body}" escape="false" style="font-weight:bold"/><h:outputText value=" #{story.openingLine.connective}" style="margin-left:5px"/>
		                	<br/>
						  	<h:dataTable value="#{story.body}" var="line">
						  		<h:column>
						  			<h:outputText value="#{line.body}" escape="false" style="font-weight:bold; margin-left:15px"/> <h:outputText value=" #{line.connective}" style="margin-left:5px"/> <br/>
						  		</h:column>
						  	</h:dataTable>
						  	<br/> <br/>
						  </h:column>
						</h:dataTable>						                
                </rich:toolTip>    
                </s:link>
				<c:if test="#{not status.last}">,<h:outputText value=" "/></c:if>
	    	</c:forEach>
		</p:panel>
	        
</ui:composition>
